package cn.gdut.chengcai.enums;

import org.apache.commons.lang.StringUtils;

/**
 * 会员注册类型
 *
 * @author gates
 *
 */
public enum MemberRegisterType {
	ACCOUNT(1), // 账号
	EMAIL(2), // 邮箱
	MOBILE(3);// 手机

	private int value;

	private MemberRegisterType(int value) {
		this.value = value;
	}

	public int getValue() {
		return value;
	}

	public String getString() {
		return getString(this.value);
	}

	public static String getString(Integer value) {
		String result = "未知";
		if (StringUtils.isEmpty(value.toString()) == true) {
			return result;
		}
		if (value == MemberRegisterType.ACCOUNT.getValue()) {
			result = "账号";
		} else if (value == MemberRegisterType.EMAIL.getValue()) {
			result = "邮箱";
		} else if (value == MemberRegisterType.MOBILE.getValue()) {
			result = "手机";
		}
		return result;
	}

	public static Integer getInteger(String value) {
		Integer result = 0;
		if (value.equals("账号")) {
			result = MemberRegisterType.ACCOUNT.getValue();
		} else if (value.equals("邮箱")) {
			result = MemberRegisterType.EMAIL.getValue();
		} else if (value.equals("手机")) {
			result = MemberRegisterType.MOBILE.getValue();
		}
		return result;
	}
}